package com.moli.iov.open.service.impl;

import com.moli.iov.down.model.dto.req.VehicleCommandThirdDto;
import com.moli.iov.down.remote.IVehicleCommandThirdRemoteService;
import com.moli.iov.open.model.vo.req.VehicleCommandThirdVo;
import com.moli.iov.open.service.IVehicleCommandFacadeService;
import com.moli.iov.rest.RestResponse;
import com.moli.iov.util.CommonUtils;
import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.Reference;
import org.springframework.stereotype.Service;

/**
 * <p>
 *
 * </p>
 *
 * @author zql
 * @since 2020/4/2 14:57
 */
@Slf4j
@Service
public class VehicleCommandFacadeServiceImpl implements IVehicleCommandFacadeService {

  @Reference(group = "${service.group}", check = false)
  private IVehicleCommandThirdRemoteService vehicleCommandThirdRemoteService;

  /**
   * 控车
   * @param vehicleCommandThirdVo
   * @return
   */
  @Override
  public RestResponse sendCommand(VehicleCommandThirdVo vehicleCommandThirdVo) {
    return vehicleCommandThirdRemoteService.sendCommand(convert(vehicleCommandThirdVo));
  }

  private VehicleCommandThirdDto convert(VehicleCommandThirdVo vehicleCommandThirdVo){
    VehicleCommandThirdDto vehicleCommandThirdDto = new VehicleCommandThirdDto();
    CommonUtils.copyProperties(vehicleCommandThirdVo, vehicleCommandThirdDto);
    vehicleCommandThirdDto.setSysCompanyId(vehicleCommandThirdVo.getCompanyId());
    return vehicleCommandThirdDto;
  }
}
